﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using BusinessLogic;

namespace Presentation.Content
{
    public partial class login : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            Session["userId"] = -1;
            Session["userRole"] = "";
        }

        protected void btnLogin_Click(object sender, EventArgs e)
        {
            long id = PersonBL.validateUser(txtUserName.Text, txtPass.Text);
            if (id != -1)
            {
                Session["userId"] = id;
                Session["userRole"] = PersonBL.getRoleById(id);
                Response.Redirect("~/Content/home.aspx");
            }
            else
            {
                lblErrorLogin.Text = "El nombre de usuario y/o la contraseña no son correctos";
            }
        }
    }
}